﻿Imports Llama

Public Module QualityCheck2
    Public Sub Run()

        Dim ps = System.Diagnostics.Process.GetProcessesByName("draft")
        If ps.Length() > 0 Then
            For Each x In ps
                x.Kill()
            Next
        End If
        Dim dsResult As DataSet = New DataSet() '用于在result.vb里
        '步骤1，选图纸
        Dim objDrawings As New LMDrawings
        GetDwgCol(DS, DrawingCol, objDrawings)

        Dim x2 As New QualityCheck.Main(MyPIDConn, objDrawings)
        dsResult = x2.CheckRedundantBreak()
        Dim RES2 As New Result(dsResult)
        RES2.ShowDialog()

        x2 = Nothing
        Exit Sub



        Dim sql As String = ""
        '属性
        Dim dtProps_PipeRun As New DataTable
        Dim sqlProps = ""
        sql = $"SELECT t.unique_name,t2.entity_name FROM xxxSchemaName.uniqueatts t
join xxxSchemaName.entities t2 on t.entity_number=t2.entity_number
where t2.entity_number in (4,22,29) and t.unique_name not like 'SP_%' AND t.unique_name not like '%.%' and t.unique_name !='UpdateCount'
order by t.unique_name
"
        MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDAppDictionary_User, sql, dtProps_PipeRun)
        For index = 0 To dtProps_PipeRun.Rows.Count - 1
            sqlProps += "," + dtProps_PipeRun.Rows(index)(1).ToString() + "." + dtProps_PipeRun.Rows(index)(0).ToString()
        Next

        sqlProps = sqlProps.Substring(1)
        Dim resDt As New DataTable
        resDt.TableName = "冗余断点"
        resDt.Columns.Add("对象类型") ： resDt.Columns.Add("现有ItemTag") ： resDt.Columns.Add("ID") ： resDt.Columns.Add("所在图纸") ： resDt.Columns.Add("管径") : resDt.Columns.Add("等级") : resDt.Columns.Add("备注")


        For Each objDrawing As LMDrawing In objDrawings
            'Dim objRuns As New LMPipeRuns
            'Dim objFilter As New LMAFilter
            'With objFilter
            '    .ItemType = "Piperun"
            '    .Criteria.AddNew("1")
            '    .Criteria.Item("1").SourceAttributeName = "Representation.Drawing.Name"
            '    .Criteria.Item("1").ValueAttribute = objDrawing("name").ToString
            '    .Criteria.Item("1").Operator = "="
            'End With
            'objRuns.Collect(DS, Filter:=objFilter) '这样属性实在太多了

            Dim dtRuns As New DataTable
            Dim dtRunsNoID As New DataTable
            Dim dtBranchs As New DataTable
            Dim dtRunsOnBranch As New DataTable
            Dim dtValveRel As New DataTable
            Try
                sql = $"SELECT t_piperun.SP_ID,{sqlProps}
FROM xxxSchemaName.t_piperun
join xxxSchemaName.t_modelitem on t_modelitem.sp_id=t_piperun.sp_id
join xxxSchemaName.t_plantitem on t_plantitem.sp_id=t_modelitem.sp_id
join xxxSchemaName.t_representation t4 on t4.sp_modelitemid=t_piperun.sp_id
join xxxSchemaName.t_drawing t5 on t5.sp_id=t4.sp_drawingid where t5.name = '{objDrawing.Name}' and t4.representationtype='13'
order by {sqlProps}
"
                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtRuns) '感觉后面这些属性值完全没有用
                '------按宁波院的意思，除了SPID之外的都相同才算一样，所以这个dtRunsNoID的列估计要改一改-----------------------
                sql = $"SELECT {sqlProps}
FROM xxxSchemaName.t_piperun
join xxxSchemaName.t_modelitem on t_modelitem.sp_id=t_piperun.sp_id
join xxxSchemaName.t_plantitem on t_plantitem.sp_id=t_modelitem.sp_id
join xxxSchemaName.t_representation t4 on t4.sp_modelitemid=t_piperun.sp_id
join xxxSchemaName.t_drawing t5 on t5.sp_id=t4.sp_drawingid where t5.name = '{objDrawing.Name}' and t4.representationtype='13'
order by {sqlProps}
"
                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtRunsNoID) 'noID 指的没有查sp_id，记录和dtRuns是一致的，除了先后顺序
                If dtRunsNoID.Rows.Count = 0 Then
                    Continue For
                End If
                sql = $"select t.sp_id,t.graphicoid,SP_modelitemID
from xxxSchemaName.t_representation t
where t.sp_drawingid = '{objDrawing.Id}' and t.representationtype = 46 "
                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtBranchs) '根据spid查到所有的分支rep（断点两边的线也认为是分支）
                sql = $"select t3.itemtag,t3.sp_id,t.sp_connectitem1id,t.sp_connectitem2id
from xxxSchemaName.t_connector t 
join  xxxSchemaName.t_representation t2 on t2.sp_id=t.sp_id 
join  xxxSchemaName.t_plantitem t3 on t3.sp_id=t2.sp_modelitemid  
where t2.sp_drawingid = '{objDrawing.Id}'"

                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtRunsOnBranch) '每个分支关联的若干个connector

                sql = $"SELECT T.SP_ID,T.SP_MODELITEMID,T3.ITEMTAG,T4.SP_MODELITEMID RUN1ID,T5.SP_MODELITEMID RUN2ID
FROM xxxSchemaName.T_REPRESENTATION T
JOIN xxxSchemaName.T_PLANTITEM T3 ON T3.SP_ID=T.SP_MODELITEMID 
LEFT JOIN xxxSchemaName.T_RELATIONSHIP R1 ON R1.SP_ITEM1ID=T.SP_ID
LEFT JOIN xxxSchemaName.T_REPRESENTATION T4 ON T4.SP_ID=R1.SP_ITEM2ID
LEFT JOIN xxxSchemaName.T_RELATIONSHIP R2 ON R2.SP_ITEM2ID=T.SP_ID
LEFT JOIN xxxSchemaName.T_REPRESENTATION T5 ON T5.SP_ID=R2.SP_ITEM1ID
WHERE T.REPRESENTATIONTYPE='13' AND T.SP_DRAWINGID='{objDrawing.Id}'"
                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtValveRel) '每个元件（如阀门）两边的connid。2023 12 9 陈玉娟的需求

            Catch ex As Exception
                MessageBox.Show("无法查询管道信息 .")
                Exit Sub
            End Try
            Dim curGroupCondition = dtRunsNoID.Rows(0) '用于比较用
            Dim curGroupIDs As New List(Of String) '当前属性相同的一组run的id的集合
            curGroupIDs.Add("'" + dtRuns.Rows(0)("SP_ID").ToString + "'")

            For i = 1 To dtRunsNoID.Rows.Count - 1 '遍历每一个在图上的pipe run
                For col = 0 To dtRunsNoID.Columns.Count - 1 '遍历每一个需要比较的属性
                    If curGroupCondition(col).ToString <> dtRunsNoID.Rows(i)(col).ToString Then '值不一样，就说明属于不同的组，然后去处理之前一组里的所有pipe run
                        '当前组进行处理
                        If curGroupIDs.Count > 1 Then
                            Dim IDs As String = "" '属性相同的run的 id 集合 
                            IDs = String.Join(",", curGroupIDs)

                            Dim Branchs = dtBranchs.Select($"SP_modelitemID in ({IDs})")
                            If Branchs.Count > 0 Then
#Region "这是最正常的断点"

                                For xx = 0 To Branchs.Count - 1
                                    Dim BranchRes = dtRunsOnBranch.Select($"sp_connectitem1id = '{Branchs(xx)("sp_id").ToString}' or sp_connectitem2id = '{Branchs(xx)("sp_id").ToString}'")
                                    If BranchRes.Count <> 3 Then '3个是正常情况，不是有断点的那种
                                        '进到这里就是断点的情况里，数量会是2
                                        Dim runIDs As String = "" '每个分支对应的run的id
                                        For Each run As DataRow In BranchRes
                                            runIDs += run("sp_id").ToString + ","
                                        Next

                                        Dim newRow As DataRow = resDt.NewRow
                                        newRow("对象类型") = "PipeRun"
                                        newRow("现有ItemTag") = BranchRes(0)("itemtag").ToString
                                        newRow("ID") = Branchs(xx)("sp_id").ToString '这个是representation ID，不是SPID
                                        newRow("所在图纸") = objDrawing.Name
                                        newRow("备注") = "此处有不必要的打断。相关管子ID: " + runIDs
                                        Try
                                            Dim objPipe As LMPipeRun = DS.GetPipeRun(BranchRes(0)("SP_ID").ToString)
                                            If Not IsNothing(objPipe) Then
                                                newRow("管径") = objPipe.Attributes("NominalDiameter").Value
                                                newRow("等级") = objPipe.Attributes("pipingmaterialsclass").Value
                                            End If
                                        Catch ex As Exception

                                        End Try


                                        resDt.Rows.Add(newRow)
                                    End If
                                Next
#End Region

                            Else
                                '依次循环curGroupID中的每2个，去relationship表里找
#Region "阀门两边" '如果阀门2边都打断的话，一边其实有一个零长管线出来，相当于上面最正常的断点
                                For conn1 = 0 To curGroupIDs.Count - 1 - 1
                                    For conn2 = conn1 + 1 To curGroupIDs.Count - 1
                                        Dim found = False
                                        Dim RelRes As DataRow() = dtValveRel.Select($"(RUN1ID = {curGroupIDs(conn1)} and RUN2ID = {curGroupIDs(conn2)}) or (RUN2ID = {curGroupIDs(conn1)} and RUN1ID = {curGroupIDs(conn2)})")
                                        If RelRes.Count = 1 Then
                                            found = True
                                        Else
                                            RelRes = dtValveRel.Select($"RUN1ID = {curGroupIDs(conn1)} or RUN1ID = {curGroupIDs(conn2)}")
                                            If RelRes.Count = 2 Then
                                                found = True
                                            Else
                                                RelRes = dtValveRel.Select($"RUN2ID = {curGroupIDs(conn1)} or RUN2ID = {curGroupIDs(conn2)}")
                                                If RelRes.Count = 2 Then
                                                    found = True
                                                End If
                                            End If
                                        End If

                                        If found And RelRes(0)("SP_MODELITEMID").ToString() = RelRes(1)("SP_MODELITEMID").ToString() Then
                                            '2个conn 属于一个阀门的两边
                                            Dim newRow As DataRow = resDt.NewRow
                                            newRow("对象类型") = "PipeRun"
                                            newRow("现有ItemTag") = RelRes(0)("ITEMTAG").ToString()
                                            newRow("ID") = RelRes(0)("SP_ID").ToString() '需要的是rep id，这样才能定位跳转
                                            newRow("所在图纸") = objDrawing.Name
                                            newRow("备注") = "此处的元件两侧，有不必要的打断。"

                                            resDt.Rows.Add(newRow)
                                        End If
                                    Next
                                Next
#End Region
                            End If
                            Branchs = Nothing
                        Else
                            '一个组就一个，也就没必要里
                        End If

                        '进入到下一组
                        Debug.Print("当前组的行：" + i.ToString)
                        curGroupCondition = dtRunsNoID.Rows(i)
                        curGroupIDs.Clear()
                        Exit For '去下面的add
                    End If
                Next


                curGroupIDs.Add("'" + dtRuns.Rows(i)("SP_ID").ToString + "'")
            Next
#Region "最后一组"
            If curGroupIDs.Count > 1 Then
                Dim IDs As String = "" '属性相同的run的 id 集合 
                IDs = String.Join(",", curGroupIDs)

                Dim Branchs = dtBranchs.Select($"SP_modelitemID in ({IDs})")

                For xx = 0 To Branchs.Count - 1
                    Dim BranchRes = dtRunsOnBranch.Select($"sp_connectitem1id = '{Branchs(xx)("sp_id").ToString}' or sp_connectitem2id = '{Branchs(xx)("sp_id").ToString}'")
                    If BranchRes.Count <> 3 Then '3个是正常情况，不是有断点的那种
                        '进到这里就是断点的情况里，数量会是2
                        Dim runIDs As String = "" '每个分支对应的run的id
                        For Each run As DataRow In BranchRes
                            runIDs += run("sp_id").ToString + ","
                        Next

                        Dim newRow As DataRow = resDt.NewRow
                        newRow("对象类型") = "PipeRun"
                        newRow("现有ItemTag") = BranchRes(0)("itemtag").ToString
                        newRow("ID") = Branchs(xx)("sp_id").ToString '这个是representation ID，不是SPID
                        newRow("所在图纸") = objDrawing.Name
                        newRow("备注") = "此处有不必要的打断。相关管子ID: " + runIDs
                        Try
                            Dim objPipe As LMPipeRun = DS.GetPipeRun(BranchRes(0)("SP_ID").ToString)
                            If Not IsNothing(objPipe) Then
                                newRow("管径") = objPipe.Attributes("NominalDiameter").Value
                                newRow("等级") = objPipe.Attributes("pipingmaterialsclass").Value
                            End If
                        Catch ex As Exception

                        End Try


                        resDt.Rows.Add(newRow)
                    End If
                Next

                Branchs = Nothing
            Else
                '一个组就一个，也就没必要里
            End If
#End Region

            dtRuns = Nothing
            dtRunsNoID = Nothing
            dtBranchs = Nothing
            dtRunsOnBranch = Nothing
            dtValveRel = Nothing
        Next

        dsResult.Tables.Clear()
        dsResult.Tables.Add(resDt)
        Dim RES As New Result(dsResult)
        RES.ShowDialog()
        Exit Sub
#Region "OLD(NOT USED)"
        '        Dim resDt As New DataTable
        '        resDt.Columns.Add("对象类型") ： resDt.Columns.Add("现有ItemTag") ： resDt.Columns.Add("ID") ： resDt.Columns.Add("所在图纸") ： resDt.Columns.Add("管径") : resDt.Columns.Add("等级") : resDt.Columns.Add("备注")

        '        '步骤1，选图纸
        '        Dim objDrawings As New LMDrawings
        '        GetDwgCol(DS, DrawingCol, objDrawings)
        '        For Each objDrawing As LMDrawing In objDrawings
        '            'Dim objRuns As New LMPipeRuns
        '            'Dim objFilter As New LMAFilter
        '            'With objFilter
        '            '    .ItemType = "Piperun"
        '            '    .Criteria.AddNew("1")
        '            '    .Criteria.Item("1").SourceAttributeName = "Representation.Drawing.Name"
        '            '    .Criteria.Item("1").ValueAttribute = objDrawing("name").ToString
        '            '    .Criteria.Item("1").Operator = "="
        '            'End With
        '            'objRuns.Collect(DS, Filter:=objFilter)
        '            Dim sql As String = ""
        '            Dim dtRuns As New DataTable
        '            Dim dtRunsNoID As New DataTable
        '            Try


        '                '                sql = $"SELECT t.sp_id,tagsequenceno,fluidsystem,operfluidcode,itemtag,tagsuffix,cleaningreqmts,coatingreqmts,corrosionallowance,flowdirection,insultype,insulthick,insultemp,insulationspec,insulpurpose,insulationnomdia,insuldensity,materialofconstclass,nominaldiameter,pipingmaterialsclass,scheduleorthickness,slope
        '                'FROM xxxSchemaName.t_piperun t
        '                'join xxxSchemaName.t_modelitem t2 on t2.sp_id=t.sp_id
        '                'join xxxSchemaName.t_plantitem t3 on t3.sp_id=t.sp_id
        '                'join xxxSchemaName.t_representation t4 on t4.sp_modelitemid=t.sp_id
        '                'join xxxSchemaName.t_drawing t5 on t5.sp_id=t4.sp_drawingid where t5.name = '{objDrawing.Name}' and t4.representationtype='13'
        '                'order by tagsequenceno,fluidsystem,operfluidcode,itemtag,tagsuffix,cleaningreqmts,coatingreqmts,corrosionallowance,flowdirection,insultype,insulthick,insultemp,insulationspec,insulpurpose,insulationnomdia,insuldensity,materialofconstclass,nominaldiameter,pipingmaterialsclass,scheduleorthickness,slope
        '                '"
        '                sql = $"SELECT T.SP_ID,tagsequenceno,fluidsystem
        'FROM xxxSchemaName.t_piperun t
        'join xxxSchemaName.t_modelitem t2 on t2.sp_id=t.sp_id
        'join xxxSchemaName.t_plantitem t3 on t3.sp_id=t.sp_id
        'join xxxSchemaName.t_representation t4 on t4.sp_modelitemid=t.sp_id
        'join xxxSchemaName.t_drawing t5 on t5.sp_id=t4.sp_drawingid where t5.name = '{objDrawing.Name}' and t4.representationtype='13'
        'order by tagsequenceno,fluidsystem
        '"
        '                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtRuns) '感觉后面这些属性值完全没有用
        '                '------按宁波院的意思，除了SPID之外的都相同才算一样，所以这个dtRunsNoID的列估计要改一改-----------------------
        '                sql = $"SELECT tagsequenceno,fluidsystem
        'FROM xxxSchemaName.t_piperun t
        'join xxxSchemaName.t_modelitem t2 on t2.sp_id=t.sp_id
        'join xxxSchemaName.t_plantitem t3 on t3.sp_id=t.sp_id
        'join xxxSchemaName.t_representation t4 on t4.sp_modelitemid=t.sp_id
        'join xxxSchemaName.t_drawing t5 on t5.sp_id=t4.sp_drawingid where t5.name = '{objDrawing.Name}' and t4.representationtype='13'
        'order by tagsequenceno,fluidsystem
        '"
        '                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, dtRunsNoID) 'noID 指的没有查sp_id，记录和dtRuns是一致的，除了先后顺序
        '                If dtRunsNoID.Rows.Count = 0 Then
        '                    Continue For
        '                End If
        '            Catch ex As Exception
        '                MessageBox.Show("无法查询管道信息 .")
        '                Exit Sub
        '            End Try
        '            Dim curGroupCondition = dtRunsNoID.Rows(0) '用于比较用
        '            Dim curGroupIDs As New List(Of String) '当前属性相同的一组run的id的集合
        '            curGroupIDs.Add(dtRuns.Rows(0)("SP_ID").ToString)

        '            For i = 1 To dtRunsNoID.Rows.Count - 1 '第一行给了curGroupCondition
        '                For col = 0 To dtRunsNoID.Columns.Count - 1 '每一列
        '                    If curGroupCondition(col).ToString <> dtRunsNoID.Rows(i)(col).ToString Then '值不一样，就说明属于不同的组（就是说如果有断点时，是冗余的概念）
        '                        '当前组进行处理
        '                        If curGroupIDs.Count > 1 Then
        '                            Dim IDs As String = "" '属性相同的run的 id 集合
        '                            For z = 0 To curGroupIDs.Count - 1
        '                                '                                Debug.Print(IDs("SP_ID").ToString)
        '                                IDs += $"'{curGroupIDs.Item(z)}',"

        '                            Next
        '                            IDs = IDs.Substring(0, Len(IDs) - 1)
        '                            sql = $"select t.sp_id,t.graphicoid
        'from xxxSchemaName.t_representation t
        'where t.sp_modelitemid in ({IDs}) and t.representationtype = 46 "
        '                            Dim Branchs As New DataTable
        '                            MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, Branchs) '根据spid查到所有的分支rep（断点也认为是分支）
        '                            '每2个conn之间22比较
        '                            For xx = 0 To Branchs.Rows.Count - 1
        '                                sql = $"select t3.itemtag,t3.sp_id from  xxxSchemaName.t_connector t 
        'join  xxxSchemaName.t_representation t2 on t2.sp_id=t.sp_id 
        'join  xxxSchemaName.t_plantitem t3 on t3.sp_id=t2.sp_modelitemid  
        'where t.sp_connectitem1id='{Branchs.Rows(xx)("sp_id").ToString}' or  t.sp_connectitem2id='{Branchs.Rows(xx)("sp_id").ToString}'"
        '                                Dim BranchRes As New DataTable
        '                                MyPIDConn.PIDReadDataByDBA(MyPIDConn.PIDPlant_DBNAME, MyPIDConn.ActivePlantPIDApp_User, sql, BranchRes) '每个分支关联的若干个connector
        '                                If BranchRes.Rows.Count <> 3 Then '3个是正常情况，不是有断点的那种
        '                                    '进到这里就是断点的情况里，数量会是2
        '                                    Dim runIDs As String = "" '每个分支对应的run的id
        '                                    For Each run As DataRow In BranchRes.Rows
        '                                        runIDs += run("sp_id").ToString + ","
        '                                    Next

        '                                    '有问题
        '                                    Dim newRow As DataRow = resDt.NewRow
        '                                    newRow("对象类型") = "PipeRun"
        '                                    newRow("现有ItemTag") = BranchRes.Rows(0)("itemtag").ToString
        '                                    newRow("ID") = Branchs.Rows(xx)("sp_id").ToString '这个是representation ID，不是SPID
        '                                    newRow("所在图纸") = objDrawing.Name
        '                                    newRow("备注") = "此处有不必要的打断。相关管子ID: " + runIDs
        '                                    Try
        '                                        Dim objPipe As LMPipeRun = DS.GetPipeRun(BranchRes.Rows(0)("SP_ID").ToString)
        '                                        If Not IsNothing(objPipe) Then
        '                                            newRow("管径") = objPipe.Attributes("NominalDiameter").Value
        '                                            newRow("等级") = objPipe.Attributes("pipingmaterialsclass").Value
        '                                        End If
        '                                    Catch ex As Exception

        '                                    End Try


        '                                    resDt.Rows.Add(newRow)
        '                                End If
        '                            Next

        '                            Branchs = Nothing
        '                        End If

        '                        '进入到下一组
        '                        Debug.Print("当前组的行：" + i.ToString)
        '                        curGroupCondition = dtRunsNoID.Rows(i)
        '                        curGroupIDs.Clear()
        '                        Exit For
        '                    End If
        '                Next
        '                curGroupIDs.Add(dtRuns.Rows(i)("SP_ID").ToString)
        '            Next


        '            '                For Each runs As DataRow In dtRuns.Rows
        '            '                    If Convert.ToInt16(runs("count")) > 1 Then
        '            '                        Dim whereSQL As String = ""
        '            '                        For i = 0 To dtRuns.Columns.Count - 2  '-2 不是 -1 是把最后一列的count给拿走
        '            '                            If runs(i).ToString() = "" Then

        '            '                                whereSQL += $" and ({dtRuns.Columns(i).ColumnName.ToString} = '{runs(i).ToString()}' or {dtRuns.Columns(i).ColumnName.ToString} is null) "
        '            '                            Else

        '            '                                whereSQL += $" and {dtRuns.Columns(i).ColumnName.ToString} = '{runs(i).ToString()}' "
        '            '                            End If
        '            '                        Next
        '            '                        sql = $"SELECT distinct T.SP_ID 
        '            'FROM xxxSchemaName.t_piperun t
        '            'join xxxSchemaName.t_modelitem t2 on t2.sp_id=t.sp_id
        '            'join xxxSchemaName.t_plantitem t3 on t3.sp_id=t.sp_id
        '            'join xxxSchemaName.t_representation t4 on t4.sp_modelitemid=t.sp_id WHERE 1 = 1 {whereSQL}"
        '            '                        Dim dtIDs As New DataTable
        '            '                        MyPIDDBConn.PIDReadDataByDBA(MyPIDDBConn.PIDPlant_DBNAME, MyPIDDBConn.ActivePlantPIDApp_User, sql, dtIDs)
        '            '                        If dtIDs.Rows.Count > 1 Then '等于1就不必了
        '            '                            For Each IDs As DataRow In dtIDs.Rows
        '            '                                Debug.Print(IDs("SP_ID").ToString)
        '            '                            Next
        '            '                        End If
        '            '                        dtIDs = Nothing
        '            '                    End If

        '            '                Next
        '            dtRuns = Nothing : dtRunsNoID = Nothing
        '        Next
#End Region
    End Sub
End Module
